package com.shuzijun.leetcode.editor.cn;
public class NumberOf1Bits{
    public static void main(String[] args) {
         Solution solution = new NumberOf1Bits().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
public class Solution {
    // you need to treat n as an unsigned value
    public int hammingWeight(int n) {
       int oneCount = 0;
       int mask = 1;
        for (int i = 0; i < 32; i++) {
            if ((n&mask) != 0){
                oneCount++;
            }
            mask <<=1;
        }
        return oneCount;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}